<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include "../public/include/funcs.php";
$cfg_dbname = "wx";
$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$id = $_GET['id'] ? $_GET['id'] : 1;
$arr = select($link, "product", "id=$id");

$imgArr = explode(";", $arr[0]['pimg']);
$img1 = $imgArr[0];
$pname = $arr[0]['pname'];
$money = $arr[0]['money'];


/*Array
(
    [0] => Array
        (
            [id] => 25
            [rank] => 9999
            [on_line] => 1
            [tid] => 1
            [pname] => 基础洁牙
            [pimg] => 08/11/09_23_17 _ 488.jpg;06/11/16_59_53 _ 620.jpg
            [description] => 基础洁牙
            [old_money] => 260
            [money] => 199
            [out_of] => 1564
            [pimg_long] => 08/11/09_23_17 _ 685.jpg
            [create_time] => 2020-06-11 16:59:53
        )

)*/
//echo "<pre>";
//print_r($arr);
//print_r($imgArr);
//echo "</pre>";

?>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>分享商城 -- 商品详情</title>
	
	<!-- Bootstrap -->
	<link href="/public/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="public/main.css"/>
	
	<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
	<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
	<![endif]-->
</head>
<body>

<div class="container">
	<img class="list-logo" src="imgs/list/logo.png"/>
</div>

<div class="container-fluid" style="padding: 0;">
	<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
		<!-- Indicators -->
		<ol class="carousel-indicators">
<?php
foreach($imgArr as $k=>$v){
	if($k == 0){
		echo '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>';
	}else{
		echo '<li data-target="#carousel-example-generic" data-slide-to="'.$k.'"></li>';
	}
}
?>
		</ol>

		<!-- Wrapper for slides -->
		<div class="carousel-inner" role="listbox">
<?php
foreach($imgArr as $k=>$v){
	$img = $domain."/files/upload/".$v;
	if($k == 0){
		echo '<div class="item active">
				<img src="'.$img.'" alt="...">
				<div class="carousel-caption">
					<!--介绍文字1-->
				</div>
			</div>';
	}else{
		echo '<div class="item">
				<img src="'.$img.'" alt="...">
				<div class="carousel-caption">
					<!--介绍文字2-->
				</div>
			</div>';
	}
}
?>
		</div>

	</div>
</div>

<div class="container">
	<p class="g-title"><?php echo $pname;?></p>
	<p>
		<span class="span-l">￥<?php echo $money;?></span>
		<span class="span-r">已售：<?php echo $arr[0]['out_of'];?></span>
	</p>
	<p class="g-desc"><?php echo $arr[0]['description'];?></p>
</div>

<div class="container">
	<p class="g-jj">商品详情</p>
<?php
	if($arr[0]['pimg_long']){
		$src = $domain."/files/upload/".$arr[0]['pimg_long'];
		echo '<img width="100%" src="'.$src.'"/>';
	}else{
		echo '暂无商品详情图...';
	}

?>
</div>






<div class="h400"></div>
<div class="footer-g">
	<a href="index.php">
		<div class="list-g">
			<span class="glyphicon glyphicon-home"></span> <br />
			<p>首页</p>
		</div>
	</a>
	<a href="list.php">
		<div class="list-g">
			<span class="glyphicon glyphicon-list"></span> <br />
			<p>分类</p>
		</div>
	</a>
	<a href="user.php">
		<div class="list-g">
			<span class="glyphicon glyphicon-user"></span> <br />
			<p>个人中心</p>
		</div>
	</a>
	<!--<a href="javascript:pay()">-->
	<a href="../../wxpay/dsm_fx_jsapi.php?id=<?php echo $id;?>&get=pay">
		<div id="pay-g" class="pay-g">
			立即购买
		</div>
	</a>
</div>
<?php //include "template/footer_g.php";?>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
<script type="text/javascript">
	function pay(){
		alert("购买功能正在发开中...");
	}
</script>
</body>
</html>